import { SET_DATA_LIST, DELETE_DATA_LIST } from './actionsType'
import { getDataList as getDataListApi, deleteDataList as deleteDataListApi } from '../api'

export function getDataList() {
	// 异步action  都需要 redux-thunk 
	return async function (dispatch) {
		const resp = await getDataListApi()
		const { data } = resp.data
		dispatch({ type: SET_DATA_LIST, payload: data })
	}	
}	


export function deleteDataList(id) {
	// 异步action  都需要 redux-thunk 
	return async function (dispatch) {
		await deleteDataListApi({ id })
		dispatch(getDataList())
	}	
}	